#define _CRT_SECURE_NO_WARNINGS 1
#include<vector>
#include<unordered_map>
#include<functional>
#include<stack>
using namespace std;
class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        unordered_map<string, function<long long(long long, long long)>>option =
        {
            {"+", [](long long a, long long b) {return a + b; }},
            {"-", [](long long a, long long b) {return a - b; }},
            {"*", [](long long a, long long b) {return a * b; }},
            {"/", [](long long a, long long b) {return a / b; }},
        };
        stack<long long>s;
        for (auto& val : tokens) {
            if (option.count(val) == 1) {
                long long right = s.top(); s.pop();
                long long left = s.top(); s.pop();
                s.push(option[val](left, right));
            }
            else {
                s.push(stoll(val));
            }
        }
        return s.top();
    }
};